package com.ruoyi.web.controller.ucenter.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.model.user.dto.UserEmailRegisterDto;
import com.ruoyi.model.user.dto.UserInfoRegisterDto;
import com.ruoyi.model.user.dto.UserPhoneRegisterDto;
import com.ruoyi.ucenter.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : 张怀秋
 **/
@Api(tags = "注册接口(这些接口一个接口一个controller)")
@RestController
@RequestMapping("/api/u-center")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class RegisterController extends BaseController {
    private final IUserInfoService userInfoService;

    @ApiOperation("手机号注册")
    @PostMapping("/phone-register")
    public R<String> phoneRegister(@ApiParam("注册表单") @RequestBody UserPhoneRegisterDto userPhoneRegisterDto) {
        return userInfoService.phoneRegisterByDTO(userPhoneRegisterDto);
    }

    @ApiOperation("邮箱注册")
    @PostMapping("/email-register")
    public R<String> emailReister(@ApiParam("注册表单") @RequestBody UserEmailRegisterDto userRegisterDto) {
        return userInfoService.emailRegisterByDTO(userRegisterDto);
    }
    @ApiOperation("基础注册")
    @PostMapping("/register-user")
    public R<String> baseRegister(@ApiParam("注册表单") @RequestBody UserInfoRegisterDto userInfoDto){
        return userInfoService.baseRegister(userInfoDto);
    }
}
